﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace ERPStore.Offers.Repositories.Mapping
{
	internal class OfferedProductMap : EntityTypeConfiguration<Datas.OfferedProductData>
	{
		public OfferedProductMap()
		{
			this.HasKey(t => t.Id);
			Property(e => e.Id)
				.IsRequired()
				.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);

			Property(e => e.SalePrice)
				.IsOptional();

			Property(e => e.Discount)
				.IsOptional();

			Property(e => e.SaleFactor)
				.IsOptional();

			Property(e => e.FixedShippingPrice)
				.IsOptional();

			Property(e => e.ShowStrikedPrice)
				.IsOptional();

			Property(e => e.ProductId)
				.IsRequired();

			Property(e => e.OfferId)
				.IsRequired();

			this.HasRequired(i => i.Offer)
				.WithMany(i => i.Items)
				.HasForeignKey(i => i.OfferId);

			ToTable("ERPStoreOffersOfferedProduct");
		}
	}
}
